package com.trkj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trkj.dao.HouseDao;
import com.trkj.entity.HouseEntity;
import com.trkj.entity.HouseholdEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class ServiceImpl implements HouseService {
    @Autowired
    private HouseDao dao;
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<HouseEntity> selectAll(HouseEntity HouseEntity , int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<HouseEntity> List= this.dao.selectAll(HouseEntity);
        PageInfo<HouseEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }

    @Override
    public List<HouseEntity> selectHouse(){
        return dao.selectHouse();
    }

    @Override
    public Boolean updateHouse(HouseEntity houseEntity) {
        return dao.updateHouse(houseEntity);
    }

    @Override
    public Boolean delHouse(int id) {
        return dao.delHouse(id);
    }
    @Override
    public int findHsNum(HouseEntity houseEntity) {
        return dao.findHsNum(houseEntity);
    }

    @Override
    public Boolean insertHouse(HouseEntity houseEntity) {
        return dao.insertHouse(houseEntity);
    }
    @Override
    public List<HouseEntity> findHouseBiaoQian() {
        return dao.findHouseBiaoQian();
    }
    //查询所有房屋数量
    @Override
    public List<HouseEntity> HouseList(){
        return dao.HouseList();
    }
}
